#include "bo3d.h"


// Method to add a resource location to for a given resource group. 
BBDECL void __stdcall o_addResourceLocation(const char* dir, const char* locType, const char* resGroup, bool recursive)
{
	Ogre::String rG;
	Ogre::String resG = Ogre::String(resGroup);

	if(resG == "DEFAULT_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
	}
	else if(resG == "AUTODETECT_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME;
	}
	else if(resG == "INTERNAL_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME;
	}
	else
	{
		rG = resG;
	}

	try
	{
		Ogre::ResourceGroupManager::getSingleton().addResourceLocation(Ogre::String(dir), Ogre::String(locType), rG, recursive);
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}

// Create a resource group. 
BBDECL void __stdcall o_createResourceGroup(const char* name, bool inGlobalPool)
{
	Ogre::ResourceGroupManager::getSingleton().createResourceGroup(Ogre::String(name), inGlobalPool);
}

// Initialises a resource group. 
BBDECL void __stdcall o_initialiseResourceGroup(const char* resGroup)
{
	Ogre::String rG;
	Ogre::String resG = Ogre::String(resGroup);

	if(resG == "DEFAULT_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
	}
	else if(resG == "AUTODETECT_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME;
	}
	else if(resG == "INTERNAL_RESOURCE_GROUP_NAME")
	{
		rG = ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME;
	}
	else
	{
		rG = resG;
	}

	try
	{
		Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup(rG);
	}
	catch(Ogre::Exception &e)
	{
		std::cout << e.getDescription() << std::endl;
	}
}